Analyzing and Visualizing BHSC using scVAT

Huobin Tan

2018-03-28

Initializing VATEntity object

scVAT can build VATEntity object from Single-Cell RNA-seq data from a csv, sparse mtx or h5 file. Firstly, loading scVAT package

library(scVAT)
#> Warning: replacing previous import 'igraph::groups' by 'plotly::groups'
#> when loading 'scVAT'
#> Warning: replacing previous import 'shiny::dataTableOutput' by
#> 'DT::dataTableOutput' when loading 'scVAT'
#> Warning: replacing previous import 'shiny::renderDataTable' by
#> 'DT::renderDataTable' when loading 'scVAT'

Loading raw data from CSV File, then initializing VATEntity object

#loading expression matrix from CSV, The csv file should contain genes in the row and cells in the columns. 
BHSC.data <- loadCSVData("BHSC.csv")
#initializing VATEntity object using loaded data
BHSC <- initVATEntity(BHSC.data, title="BHSC")
#> 2018-03-28 22:22:40 create VAT Entity... 
#> 2018-03-28 22:22:44 Filtering cells and genes... 
#> 2018-03-28 22:22:45 Scaling and Normalizing data... 
#> 2018-03-28 22:22:49 It's done!
#print BHSC
BHSC
#> An object of  VATEntity in dataset' BHSC '
#>  15616 genes,  2143 cells.

Doing analysis

Running the base pipline, including PCA, t-SNE, and Cluster

#do PCA, pc.num = 50
BHSC <- doPCA(BHSC, pc.num = 50)
#Plot PC standard deviation
plotPCASDev(BHSC)
#> Warning: package 'bindrcpp' was built under R version 3.4.3
#do tSNE, using PC1~50
BHSC <- doTSNE(BHSC, dims = 2, use.col = 50)

Loading external analysis results

scVAT can integrate the third party anlaysis results, and visualizing them. For the demo, Loading PHATE result(via)

#specifying data file, dimensions and key value (important, the key will be used later)
BHSC <- loadAnalysisFromCSV(BHSC, "BHSC_PHATE.csv", ndims =3, key="PHATE")

Visualizing one gene expression

#plot one gene expression based on t-SNE
plotGene(BHSC, genes="Cdc20", dims = c(1,2))
#plot one gene expression based on t-SNE, no gradient, and different colors
plotGene(BHSC, genes="Cdc20", gradient= FALSE, dims = c(1,2), colors=c("grey","red"))
#plot one gene expression based on PHATE
plotGene(BHSC, genes="Cdc20", dims = c(1,2), key="PHATE")
#plot one gene expression based on PHATE (3D),parameters size and sizes set point size for 3D maps
plotGene(BHSC, genes="Cdc20", dims = c(1,2,3), key="PHATE",size=1,sizes=c(1,5))

Visualizing two or three gene expressions

#plot two genes based on tSNE
plotTwoGenes(BHSC, gene1 = "Cdc20",gene2 = "Gata1")
#plot two genes based on tSNE, and use different colors
plotTwoGenes(BHSC, gene1 = "Cdc20",gene2 = "Gata1",colors=c("grey","blue","red","black"))
#plot two genes based on PHATE, and use different colors
plotTwoGenes(BHSC, gene1 = "Cdc20", gene2 = "Gata1", dims=c(1,2,3),key = "PHATE", size=1, sizes=c(1,5))
#plot three genes based on PHATE
plotThreeGenes(BHSC, gene1 = "Cdc20", gene2 = "Gata1", gene3 = "Klf1", dims=c(1:3),key="PHATE", size =1, sizes = c(1,5))

Visualizing many gene expressions in one map at the sametime

#Plot many genes at the sametime, nrows sets row number
plotGenes(BHSC, genes = c("Cdc20","Gata1","Klf1","Ube2c"), nrows=2)

Start Web GUI

#start Web GUI for visualization, clustering manually, and differential analysis
startVATGUI("BHSC")
#> Loading required package: shiny
#> Warning: package 'shiny' was built under R version 3.4.3
#> Loading required package: shinydashboard
#> Warning: package 'shinydashboard' was built under R version 3.4.3
#> 
#> Attaching package: 'shinydashboard'
#> The following object is masked from 'package:graphics':
#> 
#>     box
#> Loading required package: plotly
#> Warning: package 'plotly' was built under R version 3.4.3
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 3.4.3
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout
#> 
#> Listening on http://127.0.0.1:7312